#include<iostream>
#include<cstring>
using namespace std;
const int N = 510;
int x1, x2, m;
int h[N], e[N], ne[N], idx;
bool st[N];
int match[N];
int ans;
void add(int a, int b)
{
	e[idx] = b;
	ne[idx] = h[a];
	h[a] = idx++;
}
bool dfs(int x)
{
	for (int i = h[x]; ~i; i = ne[i]) {
		int j = e[i];
		if (!st[j]) {
			st[j] = 1;
			if (!match[j] || dfs(match[j])) {
				match[j] = x;
				return 1;
			}
		}
	}
	return 0;
}
int main()
{
	cin >> x1 >> x2 >> m;
	memset(h, -1, sizeof(h));
	while (m--) {
		int a, b;
		cin >> a >> b;
		add(a, b);
	}
	for (int i = 1; i <= x1; i++) {
		memset(st, 0, sizeof(st));
		if (dfs(i)) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}